#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#define _clr(x,a) memset(x,a,sizeof(x))
using namespace std;
const int N=755;
const int INF=0x3f3f3f3f;
int x[N];
int y[N];
int n;
int r;
int a,b;
int cnt;
int g[N][N];
bool vis[N];
int pre[N];
int lowcost[N];
int roads[1005][2];
void init(){
    _clr(x,0);
    _clr(y,0);
    _clr(g,INF);
    _clr(lowcost,0);
    _clr(vis,false);
}
int distance(int i,int j){
    return (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
}
void prim(){
    int pos=1;
    int Min=INF;
    for(int i=1;i<=n;i++){
        if(i!=pos){
            lowcost[i]=g[pos][i];
        }
        pre[i]=1;
    }
    vis[pos]=true;
    for(int i=1;i<n;i++){
        Min=INF;
        for(int j=1;j<=n;j++){
            if(!vis[j] && lowcost[j]<Min){
                pos=j;
                Min=lowcost[j];
            }
        }
        int flag=0;
        if(!vis[pos]){
            for(int k=0;k<cnt;k++){
                if((pre[pos]==roads[k][0] && pos==roads[k][1]) || (pre[pos]==roads[k][1] && pos==roads[k][0])){
                    flag=1;
                    break;
                }
            }
            if(!flag){
                printf("%d %d\n",pre[pos],pos);
            }
        }
        vis[pos]=true;
        for(int j=1;j<=n;j++){
            if(!vis[j] && lowcost[j]>g[pos][j]){
                lowcost[j]=g[pos][j];
                pre[j]=pos;
            }
        }
    }
}
int main(void){
    //freopen("data.txt","r",stdin);
    scanf("%d",&n);
    init();
    for(int i=1;i<=n;i++){
        scanf("%d%d",&x[i],&y[i]);
    }
    for(int i=1;i<=n-1;i++){
        for(int j=i+1;j<=n;j++){
            g[i][j]=g[j][i]=distance(i,j);
        }
    }
    scanf("%d",&r);
    while(r--){
        scanf("%d%d",&a,&b);
        g[a][b]=g[b][a]=0;
        roads[cnt][0]=a;
        roads[cnt++][1]=b;
    }
    prim();
    return 0;
}
